package com.huike.clues.service.impl;


import com.google.j2objc.annotations.AutoreleasePool;
import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.security.Security;
import java.util.Date;
import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 *
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {

    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;
    @Autowired
    private TbClueMapper tbClueMapper;

    /**
     * @description:
     * @author: 椎名真白
     * @date: 2022-05-18 14:33 查询线索跟新信息集合
     * @param: clueId
     * @return: java.util.List<com.huike.clues.domain.TbClueTrackRecord>
     **/
    @Override
    public List<TbClueTrackRecord> selectTbClueTrackRecordById(Long clueId) {
        List<TbClueTrackRecord> list = tbClueTrackRecordMapper.selectTbClueTrackRecordById(clueId);
        return list;
    }

    /**
     * @description: 新增线索跟进信息
     * @author: 椎名真白
     * @date: 2022-05-18 14:36
     * @param: tbClueTrackRecord
     **/
    @Override
    public void add(ClueTrackRecordVo tbClueTrackRecord) {
        //从数据库获取当前操作的线索对象  将修改后的值为其赋值
        TbClue tbClue = tbClueMapper.selectTbClueById(tbClueTrackRecord.getClueId());
        //tbClue.setAge(tbClueTrackRecord.getAge());
        //tbClue.setLevel(tbClueTrackRecord.getLevel());
        //tbClue.setName(tbClueTrackRecord.getName());
        //tbClue.setNextTime(tbClueTrackRecord.getNextTime());
        //tbClue.setQq(tbClueTrackRecord.getQq());
        //tbClue.setSex(tbClueTrackRecord.getSex());
        //tbClue.setSubject(tbClueTrackRecord.getSubject());
        BeanUtils.copyProperties(tbClueTrackRecord, tbClue);
        tbClueMapper.updateTbClue(tbClue);
        //new 一个线索跟进对象 将值传入
        TbClueTrackRecord tbClueTrackRecord1 = new TbClueTrackRecord();
       /*
        tbClueTrackRecord1.setClueId(tbClueTrackRecord.getClueId());
        tbClueTrackRecord1.setSubject(tbClueTrackRecord.getSubject());
        tbClueTrackRecord1.setRecord(tbClueTrackRecord.getRecord());
        tbClueTrackRecord1.setLevel(tbClueTrackRecord.getLevel());*/
        //tbClueTrackRecord1.setType();
        //tbClueTrackRecord1.setFalseReason();
        //tbClueTrackRecord1.setCreateTime(new Date());
        //获取当前的登录人
        tbClueTrackRecord1.setCreateBy(SecurityUtils.getUsername());
        //tbClueTrackRecord1.setNextTime(tbClueTrackRecord.getNextTime());
        BeanUtils.copyProperties(tbClueTrackRecord, tbClueTrackRecord1);
        tbClueTrackRecordMapper.add(tbClueTrackRecord1);
    }


}
